import 'package:dio/dio.dart';

enum JMNetMethod { get, post, put, patch, delete }

abstract class JMNetRequest {
  Map<String, dynamic> params = {};

  /// 请求地址
  String url();

  /// 请求路径
  String path();

  /// 请求类型
  JMNetMethod method();

  /// 请求头部 (默认 {})
  Map<String, dynamic> headers() => {};

  /// 请求超时时间 (默认 10s)
  int connectTimeout() => 10;

  /// 响应超时时间 (默认 10s)
  int receiveTimeout() => 10;

  /// 是否打印日志 (默认 false)
  bool isLog() => false;

  /// 取消token (默认 CancelToken())
  CancelToken cancelToken() => CancelToken();

  /// 添加参数
  JMNetRequest add(String k, dynamic v) {
    params[k] = v;
    return this;
  }
}
